<!--
 * @Descripttion: 
 * @version: @ 1.0.0
 * @Author: 朱江洲
 * @Date: 2022-05-05 14:24:11
 * @LastEditors: 朱江洲
 * @LastEditTime: 2022-06-01 15:29:10
-->
<template>
  <div>
    <el-drawer
      title="详细信息"
      :visible.sync="dialog.dialogDrawer"
      :direction="direction"
      :with-header="false"
      size="60%"
      :modal="false"
      @close="drawerClose"
    >
      <div class="head">
        <div class="header">
          <div class="img">
            <img src="@/assets/images/icon-batch.png" alt="" />
            <h3>{{ drawerData.name }}</h3>
          </div>
          <div class="btn">
            <el-button type="primary" @click="edit" :disabled="disabled">
              编辑
            </el-button>
            <el-button
              type="primary"
              plain
              :disabled="chargeDisabled"
              @click="changeCharge"
            >
              更换负责人
            </el-button>
            <el-dropdown style="margin-left: 10px" v-if="voidDisabled">
              <el-button class="el-icon-more"></el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="annulled">
                  合同作废
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
        <div class="footer">
          <div class="information">
            <span>合同编号</span>
            <h4>{{ drawerData.code }}</h4>
          </div>
          <div class="information">
            <span>客户名称</span>
            <h4>{{ drawerData.customer }}</h4>
          </div>
          <div class="information">
            <span>合同金额</span>
            <h4>{{ drawerData.amount }}</h4>
          </div>
          <div class="information">
            <span>签约时间</span>
            <h4>{{ drawerData.contractTime }}</h4>
          </div>
        </div>
      </div>
      <div class="strip"></div>
      <div class="approve">
        <div class="approve-top">
          <div class="left">
            <div class="left-one">审批流信息</div>
            <div class="left-two">
              <el-popover placement="top-start" trigger="hover">
                <div>
                  <div>{{ drawerData.createTime }}</div>
                  <div>{{ drawerData.createBy }} 创建此申请</div>
                </div>
                <div v-for="(item, index) in applyList" :key="index">
                  <div class="record" style="margin-top: 10px">
                    <div class="time">{{ item.createTime }}</div>
                    <div class="content">
                      <span>{{ item.nickName }}</span>
                      &nbsp;
                      <span>{{ item.result | result }}</span>
                      <span>此申请</span>
                    </div>
                    <div>
                      <span>{{ item.opinion }}</span>
                    </div>
                  </div>
                </div>
                <span slot="reference" class="left-two">查看历史审批流程</span>
              </el-popover>
            </div>
          </div>
          <div class="right">
            <el-button
              type="primary"
              size="default"
              :disabled="withdrawDisabled"
              @click="withdraw"
            >
              撤回
            </el-button>
            <el-button
              v-if="auditShow"
              type="success"
              size="default"
              :disabled="onDisabled"
              @click="adopt"
            >
              同意
            </el-button>
            <el-button
              v-if="auditShow"
              type="danger"
              size="default"
              :disabled="onDisabled"
              @click="refuse"
            >
              拒绝
            </el-button>
          </div>
        </div>
        <div class="approve-bottom">
          <div class="technological">
            <div>
              <span class="technological-by">
                <el-popover placement="top-start" trigger="hover">
                  <div>
                    <div>{{ drawerData.createTime }}</div>
                    <div>{{ drawerData.createBy }} 创建此申请</div>
                  </div>
                  <span slot="reference"> {{ drawerData.createBy }}</span>
                </el-popover>
              </span>
              ：创建
            </div>
          </div>
          <div class="technological-middle">></div>
          <template v-for="(item, index) in applyList">
            <div :key="index" style="margin-right: 20px">
              <el-popover placement="top-start" trigger="hover">
                <div style="margin-bottom: 10px">
                  <div>{{ item.createTime }}</div>
                  <div>
                    <span>{{ item.nickName }}</span>
                    <span>{{ item.result | result }}</span>
                    &nbsp;
                    <span>此申请</span>
                    <div>
                      <span>{{ item.opinion }}</span>
                    </div>
                  </div>
                </div>
                <span slot="reference">{{ item.nickName }}</span>
                <span slot="reference"> {{ item.result | result }}</span>
              </el-popover>
            </div>
          </template>
        </div>
      </div>
      <div class="strip"></div>
      <div class="specific">
        <el-tabs v-model="activeName" type="border-card">
          <el-tab-pane label="活动" name="first">
            <activity
              class="activ"
              :drawerData="drawerData"
              :furtherData="furtherData"
              :dialog="dialog"
              :getfurther="getfurther"
              :activityForm="activityForm"
              :getEnclosure="getEnclosure"
            ></activity>
          </el-tab-pane>

          <el-tab-pane label="详细资料" name="second">
            <div class="basics">基础信息</div>
            <div class="basics-information">
              <el-form label-width="110px">
                <el-form-item label="合同名称："
                  >{{ drawerData.name }}
                </el-form-item>
                <el-form-item label="合同编号：">
                  {{ drawerData.code }}</el-form-item
                >
                <el-form-item label="客户名称："
                  >{{ drawerData.customer }}
                </el-form-item>
                <el-form-item label="商机名称："
                  >{{ drawerData.opportunity }}
                </el-form-item>
                <el-form-item label="合同金额：">
                  {{ drawerData.amount }}</el-form-item
                >
                <el-form-item label="签约时间："
                  >{{ drawerData.contractTime }}
                </el-form-item>
                <el-form-item label="合同开始时间：">
                  {{ drawerData.startTime }}</el-form-item
                >
                <el-form-item label="合同结束时间：">
                  {{ drawerData.finishTime }}</el-form-item
                >
                <el-form-item label="客户签约人：">
                  {{ drawerData.customerContract }}</el-form-item
                >
                <el-form-item label="公司签约人："
                  >{{ drawerData.companyContract }}
                </el-form-item>
                <el-form-item label="备注：">{{
                  drawerData.remark
                }}</el-form-item>
                <el-form-item label="合同类型：">
                  {{ drawerData.type == 1 ? "新合同" : "续约合同" }}
                </el-form-item>
              </el-form>
            </div>
            <div class="system">系统信息</div>
            <div class="basics-information">
              <el-form label-width="100px">
                <el-form-item label="负责人："
                  >{{ drawerData.directorName }}
                </el-form-item>
                <el-form-item label="更新时间："
                  >{{ drawerData.createTime }}
                </el-form-item>
                <el-form-item label="创建人：">
                  {{ drawerData.createBy }}</el-form-item
                >
                <el-form-item label="创建时间：">
                  {{ drawerData.createTime }}</el-form-item
                >
              </el-form>
            </div>
          </el-tab-pane>
          <el-tab-pane label="回款" name="third">
            <div class="">
              <el-button type="primary" size="default" @click="newPlan">
                新建回款计划
              </el-button>
              <el-table :data="planData">
                <template slot="empty" class="emptyBg">
                  <img src="@/assets/images/empty.jpg" alt="" />
                </template>
                <el-table-column label="期数" prop="issue"> </el-table-column>
                <el-table-column label="客户名称" prop="customer">
                </el-table-column>
                <el-table-column label="合同名称" prop="contract">
                </el-table-column>
                <el-table-column label="计划回款金额" prop="planAmount">
                </el-table-column>
                <el-table-column label="计划回款日期" prop="date">
                </el-table-column>
                <el-table-column label="计划回款方式" prop="type">
                  <template slot-scope="scope">
                    {{ scope.row.type | payType }}
                  </template>
                </el-table-column>
                <el-table-column label="提前几日提醒" prop="remind">
                </el-table-column>
                <el-table-column label="备注" prop="remark"> </el-table-column>
                <el-table-column label="操作" width="200">
                  <template slot-scope="scope">
                    <el-button
                      type="text"
                      size="default"
                      @click="addXshk(scope.row)"
                    >
                      新建回款
                    </el-button>
                    <el-button
                      type="text"
                      size="default"
                      @click="editPlan(scope.row)"
                    >
                      编辑
                    </el-button>
                    <el-button
                      type="text"
                      size="default"
                      @click="delPay(scope.row)"
                    >
                      删除
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
              <pagination
                v-show="planQuery.total > 0"
                :total="planQuery.total"
                :page.sync="planQuery.pageNum"
                :limit.sync="planQuery.pageSize"
                @pagination="getPlanList"
              />
            </div>
            <div class="HkBottom">
              <el-button type="primary" size="default" @click="newXshk">
                新建回款
              </el-button>
              <el-table :data="PaymentData">
                <template slot="empty" class="emptyBg">
                  <img src="@/assets/images/empty.jpg" alt="" />
                </template>
                <el-table-column label="回款编号" prop="code">
                </el-table-column>
                <el-table-column label="合同名称" prop="contract">
                </el-table-column>
                <el-table-column label="合同金额" prop="contractAmount">
                </el-table-column>
                <el-table-column label="回款金额" prop="amount">
                </el-table-column>
                <el-table-column label="期数" prop="issue"> </el-table-column>
                <el-table-column label="负责人" prop="directorName">
                </el-table-column>
                <el-table-column label="状态" prop="status">
                  <template slot-scope="scope">
                    {{ scope.row.status | status }}
                  </template>
                </el-table-column>
                <el-table-column label="回款日期" prop="date">
                </el-table-column>
              </el-table>
              <pagination
                v-show="payQuery.total > 0"
                :total="payQuery.total"
                :page.sync="payQuery.pageNum"
                :limit.sync="payQuery.pageSize"
                @pagination="getList"
              />
            </div>
          </el-tab-pane>
          <el-tab-pane label="团队人员" name="seventh">
            <div class="team">
              <div class="team-right">
                <el-button type="primary" size="default" plain @click="addTeam">
                  添加团队成员
                </el-button>
                <el-button type="primary" size="default" plain @click="outTeam">
                  退出团队
                </el-button>
              </div>
              <div class="team-left" v-if="selShow">
                <el-button
                  type="primary"
                  size="default"
                  plain
                  :disabled="tDisabled"
                  @click="editTeam"
                >
                  编辑
                </el-button>
                <el-button
                  type="primary"
                  size="default"
                  plain
                  @click="removeTeam"
                >
                  移除
                </el-button>
              </div>
            </div>
            <el-table
              :data="teamData"
              height="3rem"
              @selection-change="teamChange"
            >
              <template slot="empty" class="emptyBg">
                <img src="@/assets/images/empty.jpg" alt="" />
              </template>
              <el-table-column type="selection" width="55"> </el-table-column>
              <el-table-column label="姓名" prop="nickName"> </el-table-column>
              <el-table-column label="部门" prop="deptName"> </el-table-column>
              <el-table-column label="团队角色">
                <template slot-scope="scope">
                  {{ scope.row.isAdmin == true ? "负责人" : "成员" }}
                </template>
              </el-table-column>
              <el-table-column label="有效时间" prop="expire">
                <template slot-scope="scope">
                  {{ scope.row.expire == null ? "不限" : scope.row.expire }}
                </template>
              </el-table-column>
              <el-table-column label="权限">
                <template slot-scope="scope">
                  {{
                    scope.row.isAdmin == true
                      ? "负责人"
                      : scope.row.readonly == 0
                      ? "读写"
                      : "只读"
                  }}
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="附件" name="fourth">
            <el-upload
              class="upload-demo"
              ref="uploadFile"
              action="#"
              accept=".xlsx,.xls,.doc,.docx,.pdf"
              :file-list="fileList"
              :on-change="getFile1"
              :auto-upload="false"
              :limit="1"
              :on-remove="handleRemove1"
              style="margin-top: 10px"
            >
              <el-button class="taskBtn"> 上传附件 </el-button>
            </el-upload>
            <el-table :data="enclosureData">
              <template slot="empty" class="emptyBg">
                <img src="@/assets/images/empty.jpg" alt="" />
              </template>
              <el-table-column
                label="附件名称"
                prop="fileName"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column label="附件大小" prop="size"> </el-table-column>
              <el-table-column label="上传人" prop="createBy">
              </el-table-column>
              <el-table-column label="上传时间" prop="createTime">
              </el-table-column>
              <el-table-column label="操作">
                <template slot-scope="scope" width="200">
                  <span class="cz" @click="preview(scope.row)">预览</span>
                  <a :href="scope.row.fileUrl" class="cz">下载</a>
                  <span class="cz" @click="logShow(scope.row)">重命名</span>
                  <span class="del" @click="del(scope.row)">删除</span>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane label="操作记录" name="fifth" class="thirdTab">
            <div
              class="operation"
              v-for="(item, index) in Operation"
              :key="index"
            >
              <div class="user">
                <div class="portrait">
                  <img :src="item.avatar" alt="" />
                </div>
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="item.createBy"
                  placement="top"
                >
                  <div class="name">{{ item.createBy }}</div>
                </el-tooltip>
              </div>
              <div class="record">
                <div class="time">{{ item.createTime }}</div>
                <div class="content">
                  <div>{{ item.content }}</div>
                </div>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-drawer>
    <el-dialog title="预览" :visible.sync="show" :fullscreen="true">
      <div v-html="fileHtml"></div>
    </el-dialog>
    <el-dialog
      title="重命名"
      :visible.sync="renameShow"
      width="30%"
      style="margin-top: 200px; margin-left: 600px"
      custom-class="dialogClass"
      :close-on-click-modal="false"
    >
      <el-input
        v-model="input"
        placeholder="请输入文件名"
        size="normal"
      ></el-input>
      <span slot="footer">
        <el-button @click="renameShow = false">取消</el-button>
        <el-button type="primary" @click="rename">保存</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="撤回审批"
      :visible.sync="withdrawShow"
      width="30%"
      style="margin-top: 200px; margin-left: 600px"
      custom-class="dialogClass"
      :close-on-click-modal="false"
    >
      <el-input
        v-model="applyInput"
        placeholder="请输入撤回理由(必填)"
        type="textarea"
        maxlength="200"
        show-word-limit
        rows="4"
        size="normal"
      ></el-input>
      <span slot="footer">
        <el-button @click="withdrawShow = false">取消</el-button>
        <el-button type="primary" @click="applyInputSubmit">保存</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :title="title"
      :visible.sync="applyShow"
      width="30%"
      @close="applyClose"
      style="margin-top: 200px; margin-left: 600px"
      custom-class="dialogClass"
      :close-on-click-modal="false"
    >
      <el-input
        v-model="applyInput"
        :placeholder="placeholder"
        type="textarea"
        maxlength="200"
        show-word-limit
        rows="4"
        size="normal"
      ></el-input>
      <span slot="footer">
        <el-button @click="applyShow = false">取消</el-button>
        <el-button type="primary" @click="Submit">保存</el-button>
      </span>
    </el-dialog>
    <new-xshk
      ref="Xshk"
      :payDisabled="payDisabled"
      :dialog="dialog"
      :payShow="payShow"
      v-if="dialog.XshkDialogEject"
    ></new-xshk>
    <new-plan
      ref="plan"
      :dialog="dialog"
      v-if="dialog.newPlanShowEject"
    ></new-plan>
    <edit-user
      :dialog="dialog"
      :teamForm="teamForm"
      v-if="dialog.editTeamShowEject"
    ></edit-user>
    <join-team
      :dialog="dialog"
      v-if="dialog.joinTeamShowEject"
      :drawerData="drawerData"
      :type="type"
      :entities='entities'
    ></join-team>
    <transfer
      :dialog="dialog"
      :drawerData="drawerData"
      :type="type"
      v-if="dialog.transferShowEject"
    ></transfer>
    <new-contact
      :dialog="dialog"
      ref="contact"
      v-if="dialog.newContactShowEject"
    ></new-contact>
  </div>
</template>

<script>
import {
  getActivityBus,
  getEnclosureOppo,
  delEnclosureOppo,
  renameOppo,
  previewOppo,
  importEnclosureOppo,
} from "@/api/CRM";
import { planList, getList, planDelete } from "@/api/CRM/xshk";
import {
  withdraw,
  annulled,
  auditProcess,
  canAudit,
  audit,
} from "@/api/CRM/comtact";
import Activity from "../activity.vue";
import { OperationRecord } from "@/api/currency";
import NewXshk from "@/views/CRM/xshk/components/newXshk.vue";
import newPlan from "@/views/CRM/xshk/components/newPlan.vue";
import { teamList, deleteTeam, withdrawTeam, rw } from "@/api/team";
import EditUser from "@/components/joinTeam/editUser.vue";
import joinTeam from "@/components/joinTeam/index.vue";
import Transfer from "@/components/joinTeam/transfer.vue";
import newContact from "@/views/CRM/contract/components/newContact.vue";
export default {
  components: {
    Activity,
    NewXshk,
    newPlan,
    EditUser,
    joinTeam,
    Transfer,
    newContact,
  },
  filters: {
    result: function (val) {
      if (val == 1) {
        val = "待审批";
      } else if (val == 2) {
        val = "通过";
      } else if (val == 3) {
        val = "拒绝";
      }
      return val;
    },
    status: function (val) {
      if (val == 1) {
        val = "正常";
      } else if (val == 2) {
        val = "撤回";
      } else if (val == 3) {
        val = "通过";
      } else if (val == 4) {
        val = "拒绝";
      } else if (val == 5) {
        val = "审核中";
      }
      return val;
    },
    payType: function (val) {
      if (val == 1) {
        val = "微信支付";
      } else if (val == 2) {
        val = "支付宝支付";
      } else if (val == 3) {
        val = "网银支付";
      } else if (val == 4) {
        val = "其他";
      }
      return val;
    },
  },
  props: {
    dialog: {
      type: Object,
      required: true,
    },
    drawerData: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      entities:[],
      type: 60,
      payShow: true,
      teamIds: [],
      teamForm: {},
      selShow: false,
      tDisabled: true,
      teamMul: [],
      teamData: [],
      withdrawShow: false,
      result: "",
      title: "",
      placeholder: "",
      auditShow: false,
      payDisabled: true,
      applyInput: "",
      applyShow: false,
      activityForm: {
        type: "",
        contactTime: "",
        content: "",
        crmId: this.drawerData.id,
        crmType: 7,
      },
      input: "",
      id: "",
      renameId: "",
      renameShow: false, //重命名
      show: false, //预览
      furtherData: [],
      payQuery: {
        pageSize: 10,
        pageNum: 1,
        total: 0,
        contractId: this.drawerData.id,
      },
      planQuery: {
        pageSize: 10,
        pageNum: 1,
        total: 0,
        contractId: this.drawerData.id,
      },
      fileHtml: "",
      show: false,
      PaymentData: [],
      planData: [],
      enclosureData: [],
      Operation: [],
      fileList: [],
      activeName: "first",
      direction: "rtl",
      applyList: [],
      onDisabled: false,
      disabled: false,
      voidDisabled: true,
      chargeDisabled: false,
      withdrawDisabled: false,
    };
  },
  created() {
    this.getRecord();
    this.getEnclosure();
    this.getfurther();
    this.auditProcess();
    this.getPlanList();
    this.getList();
    this.canAudit();
    this.getTeamList();
  },
  watch: {
    "drawerData.status": {
      deep: true,
      immediate: true,
      handler(val) {
        if (val == 1 || val == 2 || val == 3 || val == 4 || val == 6) {
          this.onDisabled = true;
        }
        if (val == 3 || val == 5 || val == 6) {
          this.disabled = true;
        }
        if (val == 2 || val == 3 || val == 6) {
          this.withdrawDisabled = true;
        }
        if (val == 2 || val == 4 || val == 5 || val == 6) {
          this.voidDisabled = false;
        }
        if (val == 6) {
          this.chargeDisabled = true;
        }
      },
    },
  },
  methods: {
    // 退出团队
    outTeam() {
      withdrawTeam({
        module: 60,
        entity: this.drawerData.id,
        userId: this.drawerData.userId,
      }).then((res) => {
        this.$message.success(res.msg);
        this.getTeamList();
      });
    },
    // 移除团队成员
    removeTeam() {
      deleteTeam({
        userId: this.drawerData.userId,
        ids: this.teamIds,
      }).then((res) => {
        this.$message.success(res.msg);
        this.getTeamList();
      });
    },
    // 编辑团队列表
    editTeam() {
      this.dialog.editTeamShowEject = true;
      this.$nextTick(function () {
        this.dialog.editTeamShow = true;
      });
    },
    // 团队列表选中
    teamChange(val) {
      this.teamMul = val;
      this.teamIds = [];
      if (val.length !== 0) {
        this.selShow = true;
        this.teamForm = val[0];
        val.forEach((item) => {
          this.teamIds.push(item.id);
        });
      } else {
        this.selShow = false;
      }
      if (val.length > 1) {
        this.tDisabled = true;
      } else {
        this.tDisabled = false;
      }
    },
    // 添加团队成员
    addTeam() {
      this.dialog.joinTeamShowEject = true;
      this.entities.push(this.drawerData.id)
      this.$nextTick(() => {
        this.dialog.joinTeamShow = true;
      });
    },
    // 获取团队成员
    getTeamList() {
      teamList({
        module: 60,
        entity: this.drawerData.id,
        userId: this.drawerData.userId,
      }).then((res) => {
        this.teamData = res.data;
      });
    },
    // 同意/拒绝
    Submit() {
      if (this.result == 3 && this.applyInput == "") {
        this.$message.info("请输入拒绝理由");
      } else {
        audit({
          contractId: this.drawerData.id,
          contractName: this.drawerData.name,
          result: this.result,
          opinion: this.applyInput,
          auditUserId: this.drawerData.auditUserId,
        }).then((res) => {
          this.$message.success(res.msg);
          this.$parent.getList();
          this.dialog.dialogDrawer = false;
          this.applyShow = false;
          this.$parent.geConPrice();
        });
      }
    },
    // 关闭同意拒绝
    applyClose() {
      this.result = "";
      this.title = "";
      this.placeholder = "";
    },
    // 同意
    adopt() {
      this.result = 2;
      this.title = "审核同意";
      this.applyShow = true;
      this.placeholder = "请输入同意理由(选填)";
    },
    // 拒绝
    refuse() {
      this.result = 3;
      this.title = "审核拒绝";
      this.applyShow = true;
      this.placeholder = "请输入拒绝理由(必填)";
    },
    // 是否能   同意/拒绝
    canAudit() {
      canAudit({
        id: this.drawerData.id,
      }).then((res) => {
        this.auditShow = res.data;
      });
    },
    // 计划新建回款
    addXshk(row) {
      this.dialog.XshkDialogEject = true;
      this.payDisabled = true;
      this.$nextTick(function () {
        this.dialog.XshkDialog = true;
        this.$refs["Xshk"].planForm.customer = row.customer;
        this.$refs["Xshk"].planForm.customerId = row.customerId;
        this.$refs["Xshk"].planForm.contract = row.contract;
        this.$refs["Xshk"].planForm.contractId = row.contractId;
        this.$refs["Xshk"].getIssues();
        this.$refs["Xshk"].planForm.issue = row.issue;
      });
    },
    // 编辑回款计划
    editPlan(row) {
      this.dialog.newPlanShowEject = true;
      this.$nextTick(function () {
        this.$refs["plan"].planForm = row;
        this.dialog.newPlanShow = true;
      });
    },
    // 删除
    async delPay(row) {
      const confirmResult = await this.$confirm(
        "此操作将永久删除该回款计划, 是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).catch((err) => err);
      /*如果用户确认打印confirm,如果用户取消显示cancel*/
      if (confirmResult !== "confirm") {
        return this.$message.info("已取消删除!");
      } else {
        planDelete({ id: row.id }).then((res) => {
         
          this.$message.success("删除成功！");
          this.getPlanList();
        });
      }
    },
    // 新建回款
    newXshk() {
      this.dialog.XshkDialogEject = true;
      this.$nextTick(function () {
        this.$refs["Xshk"].planForm.customerId = this.drawerData.customerId;
        this.$refs["Xshk"].planForm.customer = this.drawerData.customer;
        this.$refs["Xshk"].planForm.contract = this.drawerData.name;
        this.$refs["Xshk"].planForm.contractId = this.drawerData.id;
        this.dialog.XshkDialog = true;
      });
    },
    // 新建回款计划
    newPlan() {
      this.dialog.newPlanShowEject = true;
      this.$nextTick(function () {
        this.$refs["plan"].planForm.customerId = this.drawerData.customerId;
        this.$refs["plan"].planForm.customer = this.drawerData.customer;
        this.$refs["plan"].planForm.contract = this.drawerData.name;
        this.$refs["plan"].planForm.contractId = this.drawerData.id;
        this.dialog.newPlanShow = true;
      });
    },
    // 获取回款列表
    getList() {
      getList(this.payQuery).then((res) => {
        this.PaymentData = res.rows;
        this.payQuery.total = res.total;
      });
    },
    // 获取回款计划列表
    getPlanList() {
      // 获取回款计划
      planList(this.planQuery).then((res) => {
        this.planData = res.rows;
        this.planQuery.total = res.total;
      });
    },
    // 确定撤回
    async applyInputSubmit() {
      if (this.applyInput == "") return this.$message.info("请输入撤回理由");
      const confirmResult = await this.$confirm(
        "此操作将撤回该合同, 是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).catch((err) => err);
      /*如果用户确认打印confirm,如果用户取消显示cancel*/
      if (confirmResult !== "confirm") {
        return this.$message.info("已取消撤回!");
      } else {
        withdraw({
          id: this.drawerData.id,
          reason: this.applyInput,
        }).then((res) => {
          this.$message.success(res.msg);
          this.dialog.dialogDrawer = false;
          this.applyInput = "";
          this.$parent.getList();
        });
      }
      // console.log('确认了删除')
    },
    // s审批流程
    auditProcess() {
      auditProcess({
        id: this.drawerData.id,
      }).then((res) => {
        console.log(res);
        this.applyList = res.data;
      });
    },
    // 作废
    async annulled() {
      const confirmResult = await this.$confirm(
        "此操作将作废该合同, 是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).catch((err) => err);
      /*如果用户确认打印confirm,如果用户取消显示cancel*/
      if (confirmResult !== "confirm") {
        return this.$message.info("已取消作废!");
      } else {
        annulled({
          id: this.drawerData.id,
        }).then((res) => {
          this.$message.success(res.msg);
          this.$parent.getList();
        });
      }
      // console.log('确认了删除')
    },
    // 撤回
    withdraw() {
      this.withdrawShow = true;
    },
    // 获取附件列表
    getEnclosure() {
      console.log(this.drawerData.id);
      getEnclosureOppo({
        opportunityId: this.drawerData.id,
        crmType: 7,
      }).then((res) => {
        this.enclosureData = res.data;
      });
    },
    // 获取跟进
    getfurther() {
      getActivityBus({
        crmId: this.drawerData.id,
        crmType: 7,
      }).then((res) => {
        this.furtherData = res.rows;
      });
    },
    // 操作记录
    getRecord() {
      OperationRecord({
        columnId: 60,
        entryId: this.drawerData.id,
      }).then((res) => {
        this.Operation = res.data;
      });
    },
    // 删除
    del(row) {
      delEnclosureOppo({
        id: row.id,
        url: row.fileUrl,
      }).then((res) => {
        this.$message.success("删除成功");
        this.getEnclosure();
      });
    },
    // 重命名
    logShow(row) {
      this.renameShow = true;
      this.renameId = row.id;
    },
    // 修改名称
    rename() {
      renameOppo({
        id: this.renameId,
        name: this.input,
      }).then((res) => {
        this.$message.success("修改成功");
        this.renameShow = false;
        this.getEnclosure();
        this.input = "";
      });
    },
    // 预览
    preview(row) {
      previewOppo({
        url: row.fileUrl,
      }).then((res) => {
        this.fileHtml = res.msg;
        this.show = true;
      });
    },
    uploadFile(file) {
      var fd = new FormData();
      fd.append("crmId", this.drawerData.id);
      fd.append("crmType", 7);
      fd.append("file", file.raw);
      importEnclosureOppo(fd).then((res) => {
        this.$message.success(res.msg);
        this.getEnclosure();
        this.$refs.uploadFile.clearFiles();
      });
    },
    getFile1(file, fileList) {
      this.uploadFile(file);
    },
    handleRemove1(file, fileList) {
      console.log(file, fileList);
    },
    // 关闭抽屉
    drawerClose() {
      this.dialog.dialogDrawerEject = false;
      this.dialog.activity = true;
      this.activityForm = {
        type: "",
        contactTime: "",
        content: "",
        crmId: this.drawerData.id,
        crmType: 7,
      };
    },
    // 编辑
    edit() {
      rw({
        module: this.type,
        entity: this.drawerData.id,
        userId: this.drawerData.userId,
      }).then((res) => {
        if (res.data == true) {
          this.dialog.newContactShowEject = true;
          this.drawerData.auditUserIds = [];
          this.$nextTick(function () {
            this.$refs["contact"].contactForm = this.drawerData;
            auditProcess({
              id: this.drawerData.id,
            }).then((res) => {
              this.$refs["contact"].examineList = res.data;
              res.data.forEach((item) => {
                this.$refs["contact"].contactForm.auditUserIds = [];
                this.$refs["contact"].contactForm.auditUserIds.push(
                  item.userId
                );
              });
            });
            this.dialog.newContactShow = true;
          });
        } else {
          this.$message.info("无编辑权限");
        }
      });
    },
    // 更换负责人
    changeCharge() {
      this.dialog.transferShowEject = true;
      this.$nextTick(function () {
        this.dialog.transferShow = true;
      });
    },
  },
};
</script>

<style lang="less" scoped>
// /deep/.el-drawer.rtl {
//   height: 96%;
//   margin-top: 1.6%;
// }
.head {
  padding: 29px;
  width: 100%;
  height: 155px;
  border-bottom: 1px solid #ececec;
  span {
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
  }
  .header {
    display: flex;
    justify-content: space-between;
    .img {
      transform: translateY(-15px);
      img {
        vertical-align: middle;
        margin-right: 12px;
      }
      h3 {
        display: inline-block;
      }
    }
  }
  .footer {
    display: flex;
    .information {
      display: flex;
      flex-direction: column;
      margin-right: 80px;
      h4 {
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #2b2b2b;
        margin-top: 12px;
      }
    }
  }
}
.strip {
  width: 100%;
  height: 16px;
  background: #fafafa;
  border: 1px solid #ececec;
  /deep/.el-tabs__nav-scroll {
    background-color: #f5f8fa;
  }
}
/deep/ .el-tab-pane {
  padding-left: 24px;
  // overflow: auto;
}

.basics {
  position: relative;
  font-size: 14px;
}

.basics::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 1px;
  width: 3px;
  height: 14px;
  background: #1267fa;
}

.system {
  margin-top: 30px;
  position: relative;
  font-size: 14px;
}

.system::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 1px;
  width: 3px;
  height: 14px;
  background: #1267fa;
}

.basics-information {
  display: flex;
  flex-wrap: wrap;
  .el-form {
    width: 100%;
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    .el-form-item {
      width: 50%;
      /deep/ .el-form-item__label {
        color: #999999;
      }
    }
  }
  .subclass {
    width: 249px;
    margin-top: 30px;
    margin-right: 150px;

    span {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      line-height: 14px;
    }
  }
}

.operation {
  display: flex;

  .user {
    display: flex;

    .portrait {
      width: 30px;
      height: 30px;
      border-radius: 30px;

      img {
        width: 100%;
        height: 100%;
        border-radius: 30px;
      }
    }

    .name {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      width: 100px;
      height: 30px;
      line-height: 30px;
      margin-left: 14px;
    }
  }

  .record {
    padding-left: 21px;
    margin-left: 44px;
    border-left: 1px dotted #dbdcdb;

    .time {
      font-size: 14px;
      position: relative;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      line-height: 14px;
    }

    .time::before {
      content: "";
      position: absolute;
      left: -27px;
      width: 11px;
      height: 11px;
      background-color: #000;
      transform: rotate(45deg);
    }

    .content {
      padding-top: 10px;
      padding-bottom: 10px;
    }
  }
}

.el-dropdown {
  margin-left: 10px;
}
// /deep/.el-drawer__body {
//   height: 100vh;
//   overflow: auto;
// }
/deep/ .el-table__header-wrapper {
  background: #f2f2f2;
}

/deep/ .el-tabs__content {
  overflow: auto;
  height: 62vh;
}

.imgUp {
  width: 100px;
  height: 100px;
  vertical-align: top;
}

.HkBottom {
  margin-top: 20px;
  padding-bottom: 80px;
}
.activ {
  width: 100%;
  height: 100%;
}
.cz {
  color: #1267fa;
  margin-left: 5px;
}
.del {
  color: #fa1212;
  margin-left: 5px;
}
.approve {
  width: 100%;
  height: 140px;
  padding: 10px 10px;
  .approve-top {
    display: flex;
    justify-content: space-between;
    .left {
      display: flex;
      align-items: center;
      .left-one {
        font-size: 18px;
        font-weight: 500;
      }
      .left-two {
        margin-left: 10px;
        color: #1267fa;
        cursor: pointer;
      }
    }
  }
  .approve-bottom {
    display: flex;
    flex-wrap: wrap;
    padding-top: 20px;
    align-items: center;
    .technological {
      .technological-by {
        font-size: 18px;
      }
    }
    .technological-middle {
      font-size: 20px;
      margin-left: 10px;
      margin-right: 10px;
      .el-popover {
        margin-right: 20px;
      }
    }
  }
}
.team {
  display: flex;
  justify-content: space-between;
}
</style>